package com.ants.common.utils;

import org.jsoup.Connection;
import org.jsoup.Jsoup;

/**
 * TODO
 * Author Chen
 * Date   2021/12/10 10:28
 */
public class CheckBaiduIncludeUrlUtil {
    /**
     * java检测百度是否收录网站url
     *
     * @param siteurl
     * @return
     */
    public static String checkBaiduInclude(String siteurl) {
        String url = "https://www.baidu.com/s?wd=" + siteurl;
        try {
            Connection.Response resp = Jsoup.connect(url)
                    .timeout(60000)
                    .method(Connection.Method.GET)
                    .maxBodySize(0)
                    .followRedirects(false)
                    .execute();
            return new String(resp.bodyAsBytes());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }

}
